<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<link rel="stylesheet" type="text/css" href="../../../Themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="../../../Themes/icon.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/demo.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/common.css">

	</head>

	<body style="padding: 0px;">
		<div class="easyui-layout" style="width:100%;height:600px;">
			<div id="div_search" data-options="region:'north'" style="height:80px;">

			</div>
			<div data-options="region:'center'">
				<div>
					<table id="dg" class="table_style">
					</table>
				</div>
			</div>
		</div>
		<div id="toolbar"></div>
		<div id="dlg" class="hiddenDialog">
			<iframe id="ifrmEdit" style="width: 100%;height: 100%;" frameborder="0" scrolling="no"></iframe>
		</div>
	</body>
	<script type="text/javascript" src="../../../JS/jquery.min.js"></script>
	<script type="text/javascript" src="../../../JS/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="../../../JS/common.js"></script>
	<script type="text/javascript" src='../../../JS/SHA-1.js'></script>
	<script type="text/javascript" src='../../../JS/User/UserSearchShareFunction.js'></script>
	<script type="text/javascript">
		var currid = getID();
		var content = "";
		var AddDialog;
		var toolbarType = TOOLBAR_ADD + TOOLBAR_EDITOR + TOOLBAR_DELETE;
		content = AddToolBar(toolbarType);
		$("#toolbar").append(content);
		getDataGrid();
		var DialogWidth = 800;
		var DialogHeight = 280;

		function newdata() {
			var pLocation = "UI/Common/UserManager/UserAdd.html?id=" + AddFlag;
			$("#ifrmEdit").attr("src", pLocation);
			constructDialog($("#dlg"), "新增用户", DialogWidth, DialogHeight);
			AddDialog.dialog('open');
		}

		function editdata() {
			var row = $("#dg").datagrid("getSelected");
			if(!row) {
				$.messager.alert("消息", "请选中数据");
				return;
			}
			var pLocation = "UI/Common/UserManager/UserAdd.html?id=" + row.ID;
			$("#ifrmEdit").attr("src", pLocation);
			constructDialog($("#dlg"), "修改用户", DialogWidth, DialogHeight);
			AddDialog.dialog('open');
		}

		function destroy() {
			var rowdata = $('#dg').datagrid('getSelected');
			if(!rowdata) {
				$.messager.alert('Info', "请选择你需要修改数据"); 
				return;
			}
			if(rowdata) {
				$.messager.confirm('Confirm', '是否删除', function(r) {
					if(r) {
						$.post(RemoteLinkAddress + "/user/delete.do", {
								ID: rowdata.ID,
							},
							function(result) {
								if(result.msg == "success") {
									$('#dg').datagrid('reload');
									$.messager.alert({
										title: '成功',
										msg: '删除成功',
									});
								} else {
									$.messager.alert({ // show error message
										title: 'Error',
										msg: result.msg
									});
								}
							},
							'json');
					}
				});
			}
		}

		function getDataGrid() {
			$('#dg').datagrid({
				url: RemoteLinkAddress + '/user/list.do',
				toolbar: '#toolbar',
				method: 'get',
				pagination: 'true',
				rownumbers: 'true',
				fitColumns: 'false',
				singleSelect: 'true',
				height: 350,
				columns: [
					[{
						field: 'ID',
						title: 'ID',
						width: '5%',
						align: 'center'
					}, {
						field: 'NAME',
						title: '姓名',
						width: '10%',
						align: 'center'
					}, {
						field: 'USERNAME',
						title: '用户名',
						width: '10%',
						align: 'center'
					}, {
						field: 'DEPARTMENT',
						title: '部门',
						width: '10%',
						align: 'center'
					}, {
						field: 'ROLE_NAME',
						title: '角色',
						width: '10%',
						align: 'center'
					}, {
						field: 'NUMBER',
						title: '身份证号码',
						width: '15%',
						align: 'center'
					}, {
						field: 'PHONE',
						title: '联系电话',
						width: '15%',
						align: 'center'
					}, {
						field: 'LAST_LOGIN',
						title: '最后一次登录',
						width: '15%',
						align: 'center'
					}]
				],
				onDblClickRow: function(index, row) {
					var pLocation = "UI/Common/UserManager/UserAdd.html?id=" + row.ID;
					$("#ifrmEdit").attr("src", pLocation);
					constructDialog($("#dlg"), "修改用户", DialogWidth, DialogHeight);
					AddDialog.dialog('open');
				}
			});
		}

		function dialogClose() {
			AddDialog.dialog('close');
		}
		////用户查询部分
		var searchType = SEARCH_NAME + SEARCH_USER_NAME + SEARCH_ROLE_NAME;
		var content = buildSearchOptions(searchType, "");
		$("#div_search").append(content);

		function doSearch() {
			var searchCondition = "";
			searchCondition = processSearchCondition();
			var _url = RemoteLinkAddress + '/user/list.do?' + searchCondition;
			$('#dg').datagrid('options').url = _url;
			$('#dg').datagrid('reload');
		}
	</script>

</html>